package com.zwr.sheller.shop.service.impl;

import com.zwr.sheller.core.common.WDMBusinessException;
import com.zwr.sheller.core.common.WDMExceptionCode;
import com.zwr.sheller.core.pojo.Order;
import com.zwr.sheller.core.pojo.OrderSku;
import com.zwr.sheller.core.pojo.OriginOrder;
import com.zwr.sheller.core.pojo.Sku;
import com.zwr.sheller.core.service.impl.BaseServiceImpl;
import com.zwr.sheller.shop.mapper.OrderMapper;
import com.zwr.sheller.shop.mapper.OrderSkuMapper;
import com.zwr.sheller.shop.mapper.OriginOrderMapper;
import com.zwr.sheller.shop.mapper.SkuMapper;
import com.zwr.sheller.shop.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import java.util.List;

/**
 * @author wdm
 */
@Service("orderService")
public class OrderServiceImpl extends BaseServiceImpl<OriginOrder> implements OrderService {
    @Autowired(required = false)
   private SkuMapper skuMapper;
    @Autowired(required = false)
   private OriginOrderMapper orderMapper;
    @Autowired(required = false)
   private OrderSkuMapper orderSkuMapper;


    @Override
    public void updateSkuStock(Sku sku) {
        int i = skuMapper.updateByPrimaryKey(sku);

    }

    @Override
    public void updateOrderField(OriginOrder order) {
        orderMapper.updateByPrimaryKey(order);
    }

    @Override
    public List<OrderSku> selectOrderSkuByFeture(Long orderId) {
        Example example = new Example(OrderSku.class);
        Example.Criteria o = example.createCriteria().andEqualTo("orderId", orderId);
        List<OrderSku> orderSkus = orderSkuMapper.selectByExample(example);
        return orderSkus;
    }
}
